<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    输入电话：<input type="number"class="ipt">
    <button class="btn">发送</button>

    <script>
        btn = document.querySelector('.btn');
        ipt = document.querySelector('.ipt');

        btn.onclick = function () {
            send(this, 10);
        }

        // 设置接口 传入 目标元素 倒计时 即可
        function send(el, time) {
            // 点击立即改变
            el.innerText = time + '秒..'
            // 设置按钮不可点击
            el.disabled = true;
            // 设置定时器倒计时
            el.timer = setInterval(function () {
                el.innerText = (--time) + '秒..';
                // 设置透明度

                if (time === 0) {
                    // 倒计时结束，恢复原来样子
                    clearInterval(el.timer);
                    el.innerText = '发送';
                    el.disabled = false;
                }
            }, 1000)
        }
    </script>
</body>
</html>